﻿using System;
using System.Web;
using System.Web.Routing;
using FubuMVC.Core;
using FubuMVC.StructureMap;
using StructureMap;

namespace behaviors
{
    public class Global
        : HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
            FubuApplication
                .For<BehaviorsRegistry>()
                .StructureMapObjectFactory(x =>
                                               {
                                                   x.AddRegistry<AppSettingProviderRegistry>();
                                                   x.Scan(s =>
                                                              {
                                                                  s.TheCallingAssembly();
                                                                  s.Convention<SettingsScanner>();
                                                              });
                                               })
                .Bootstrap(RouteTable.Routes);
        }

        protected void Application_End(object sender, EventArgs e)
        {
            ObjectFactory.Container.Dispose();
        }
    }
}